<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Dependencies</title>
</head>

<body>

<h2>JBehave modules</h2>

<p>JBehave provides the following modules, defined as POM artifacts:</p>

<table class="bodyTable">
<tr class="a"><th>Module</th><th>Versions</th></tr>
<tr class="b"><td>jbehave-core</td><td><a href="http://search.maven.org/#search|ga|1|jbehave-core/">lookup</a></td></tr>
<tr class="a"><td>jbehave-groovy</td><td><a href="http://search.maven.org/#search|ga|1|jbehave-groovy">lookup</a></td></tr>
<tr class="a"><td>jbehave-scala</td><td><a href="http://search.maven.org/#search|ga|1|jbehave-scala">lookup</a></td></tr>
<tr class="a"><td>jbehave-guice</td><td><a href="http://search.maven.org/#search|ga|1|jbehave-guice">lookup</a></td></tr>
<tr class="a"><td>jbehave-needle</td><td><a href="http://search.maven.org/#search|ga|1|jbehave-needle">lookup</a></td></tr>
<tr class="b"><td>jbehave-pico</td><td><a href="http://search.maven.org/#search|ga|1|jbehave-pico">lookup</a></td></tr>
<tr class="a"><td>jbehave-spring</td><td><a href="http://search.maven.org/#search|ga|1|jbehave-spring">lookup</a></td></tr>
<tr class="a"><td>jbehave-weld</td><td><a href="http://search.maven.org/#search|ga|1|jbehave-weld">lookup</a></td></tr>
<tr class="b"><td>jbehave-odf</td><td><a href="http://search.maven.org/#search|ga|1|jbehave-odf">lookup</a></td></tr>
<tr class="b"><td>jbehave-google</td><td><a href="http://search.maven.org/#search|ga|1|jbehave-google">lookup</a></td></tr>
<tr class="a"><td>jbehave-rest</td><td><a href="http://search.maven.org/#search|ga|1|jbehave-rest">lookup</a></td></tr>
<tr class="b"><td>jbehave-ant</td><td><a href="http://search.maven.org/#search|ga|1|jbehave-ant">lookup</a></td></tr>
<tr class="a"><td>jbehave-hudson-plugin</td><td><a href="http://search.maven.org/#search|ga|1|jbehave-hudson-plugin">lookup</a></td></tr>
<tr class="a"><td>jbehave-jenkins-plugin</td><td><a href="http://search.maven.org/#search|ga|1|jbehave-jenkins-plugin">lookup</a></td></tr>
<tr class="a"><td>jbehave-maven-plugin</td><td><a href="http://search.maven.org/#search|ga|1|jbehave-maven-plugin">lookup</a></td></tr>
<tr class="b"><td>jbehave-distribution</td><td><a href="http://search.maven.org/#search|ga|1|jbehave-distribution">lookup</a></td></tr>
</table>

<p>Once a version has been chosen, each artifact will declare the dependencies required.</p>

<span class="followup">Not all the required dependencies are found in Maven Central.  The <b>settings.xml</b> defines the repositories for those not found in Maven Central.
If you are running in a corporate environment, you may be using a Maven Repository Manager, such as Nexus, which may proxy the repositories behind a public open-source group.</span>

<p>A POM artifact can be declared as dependency using different build systems:</p>

<h3 id="maven">Apache Maven</h3>

<p>Using <a href="http://maven.apache.org">Apache Maven</a>, the dependencies are declared in the Maven pom.xml:</p>

<script type="syntaxhighlighter" class="brush: xml">
<![CDATA[
  <dependency> 
    <groupId>[groupId]</groupId>
    <artifactId>[artifactId]</artifactId>
    <version>[version]</version>
  </dependency>
]]>
</script>

<p>and the use of a custom settings.xml is declared via command line:</p>
<script type="syntaxhighlighter" class="brush: plain">
<![CDATA[
    mvn -s settings.xml <goals>
]]>
</script>

<span class="followup">Maven dependencies are by default <b>transitive</b>, i.e. a top-level dependency will pull in all the dependencies it needs.</span>

<p>To override a version of a specific dependency in the dependency tree, the most effective way is to use the dependency management of the POM, e.g.:</p>

<script type="syntaxhighlighter" class="brush: xml">
<![CDATA[
<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-library</artifactId>
      <version>1.2.1</version>
    </dependency>
  </dependencies>
</dependencyManagement>
]]>
</script>

<p>Learn more about Maven dependency management from the <a href="http://www.sonatype.com/books/mvnref-book/reference/pom-relationships-sect-project-dependencies.html">Maven: The Complete Reference</a>.</p>

<h3 id="ant">Apache Ant</h3>

<p>Using no dependency management tool, the build.xml in the <b>lib</b> directory of the binary distribution provides a target to 
copy to the lib directory all dependencies declared in the Maven pom.xm:</p>
<script type="syntaxhighlighter" class="brush: plain">
<![CDATA[
    ant copy-dependencies
]]>
</script>

<span class="followup">The Ant build.xml script uses the pom.xml to download and copy the dependencies (using the Maven Ant Tasks) as a one-off
operation.  Thereafter, Ant users can declare their dependencies from the lib directory and no further use of the pom.xml is required.</span> 

<p>Using <a href="http://maven.apache.org/ant-tasks/">Maven Ant Tasks</a>, the Ant dependency fileset can be created, with the Maven settings.xml provided
specifying the remote repositories: </p>

<script type="syntaxhighlighter" class="brush: xml">
<![CDATA[
<project name="my_project" default="build" xmlns:artifact="antlib:org.apache.maven.artifact.ant">

    <artifact:pom id="pom" file="pom.xml" settingsFile="settings.xml" />
    <artifact:dependencies filesetId="dependency.fileset" pomRefId="pom" useScope="test" />
        <dependency groupId="org.jbehave" artifactId="jbehave-ant" version="[version]"/>           
        <dependency groupId="org.jbehave" artifactId="jbehave-core" version="[version]" classifier="resources" type="zip"/>           
        <dependency groupId="org.jbehave.site" artifactId="jbehave-site-resources" version="3.1.1" type="zip"/>           
        ...
    </artifact:dependencies>

</project>
]]>
</script>

<span class="followup">Use of Maven Ant Tasks requires the <a href="http://maven.apache.org/ant-tasks/download.html">maven-ant-tasks.jar</a> 
to be present in the <b>$ANT_HOME/lib</b>.  A copy of the jar is provided in the <b>lib</b> directory of the binary distribution.</span> 

<p>Using <a href="http://ant.apache.org/ivy/">Ant Ivy</a>:</p>

<script type="syntaxhighlighter" class="brush: xml">
<![CDATA[
<dependency org="[groupId]" name="[artifactId]" rev="[version]"/>
]]>
</script>

<span class="followup">The repositories in the Maven settings.xml need to be configured as resolvers in the <a href="http://ant.apache.org/ivy/history/latest-milestone/settings.html">Ivy settings</a>.</span>

<h3 id="grape">Groovy Grape</h3>

<p>Using <a href="http://groovy.codehaus.org/grape">Groovy Grape</a>:</p>

<script type="syntaxhighlighter" class="brush: xml">
<![CDATA[
@Grapes(
    @Grab(group='[groupId]', module='[artifactId]', version='[version]')
)
]]>
</script>

<span class="followup">Grape can also understand <a href="http://ant.apache.org/ivy/history/latest-milestone/settings.html">Ivy settings</a>.</span>

</body>
</html>